package org.example.SolutionNew001;

import java.util.Arrays;

public class DoublePoint01 {
    public static void main(String[] args) {
        DoublePoint01 dp=new DoublePoint01();
        int[] nums=new int[]{12,3,1,0,0};
        dp.moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }

    public void moveZeroes1(int[] nums) {
        int n=nums.length;
        int flag=0;
        while(flag<n&&nums[flag]!=0){
            flag++;
        }
        for(int i=flag+1;i<n;i++){
            if(nums[i]!=0){
                int tmp=nums[flag];
                nums[flag]=nums[i];
                nums[i]=tmp;
                while(flag<n&&nums[flag]!=0){
                    flag++;
                }
                i=flag;
            }
        }
    }

    public void moveZeroes(int[] nums) {
        int n=nums.length,left=0,right=0;
        while (right < n) {
            if(nums[right]!=0){
                int tmp=nums[left];
                nums[left]=nums[right];
                nums[right]=tmp;
                left++;
            }
            right++;
        }
    }
}
